package com.yanfan.lighting.controller;

import java.util.Arrays;
import java.util.List;
import javax.validation.Valid;
import javax.servlet.http.HttpServletResponse;
import com.yanfan.common.utils.DateUtils;
import com.yanfan.common.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.lighting.domain.IbmsLightingLog;
import com.yanfan.lighting.service.IIbmsLightingLogService;
import com.yanfan.common.utils.poi.ExcelUtil;
import com.yanfan.common.core.page.TableDataInfo;

/**
 * 照明系统操作日志Controller
 *
 * @author genluo
 * @date 2024-08-27
 */
@Api(tags = "照明系统操作日志")
@RestController
@RequestMapping("/lighting/lightingLog")
public class IbmsLightingLogController extends BaseController {
    @Autowired
    private IIbmsLightingLogService ibmsLightingLogService;

    /**
     * 查询照明系统操作日志列表
     */
    @ApiOperation("照明系统操作日志分页列表")
    @PreAuthorize("@ss.hasPermi('lighting:lightingLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(IbmsLightingLog ibmsLightingLog) {
        startPage();
        List<IbmsLightingLog> list = ibmsLightingLogService.queryPageList(ibmsLightingLog);
        return getDataTable(list);
    }

    /**
     * 导出照明系统操作日志列表
     */
    @ApiOperation("导出照明系统操作日志列表")
    @PreAuthorize("@ss.hasPermi('lighting:lightingLog:export')")
    @Log(title = "照明系统操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IbmsLightingLog ibmsLightingLog) {
        List<IbmsLightingLog> list = ibmsLightingLogService.queryPageList(ibmsLightingLog);
        ExcelUtil<IbmsLightingLog> util = new ExcelUtil<IbmsLightingLog>(IbmsLightingLog.class);
        util.exportExcel(response, list, "照明系统操作日志数据");
    }

    /**
     * 获取照明系统操作日志详细信息
     */
    @ApiOperation("获取照明系统操作日志详细信息")
    @PreAuthorize("@ss.hasPermi('lighting:lightingLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(ibmsLightingLogService.getById(id));
    }

    /**
     * 新增照明系统操作日志
     */
    @ApiOperation("新增照明系统操作日志")
    @PreAuthorize("@ss.hasPermi('lighting:lightingLog:add')")
    @Log(title = "照明系统操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Valid @RequestBody IbmsLightingLog ibmsLightingLog) {
        return toAjax(ibmsLightingLogService.save(ibmsLightingLog));
    }

    /**
     * 修改照明系统操作日志
     */
    @ApiOperation("修改照明系统操作日志")
    @PreAuthorize("@ss.hasPermi('lighting:lightingLog:edit')")
    @Log(title = "照明系统操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Valid @RequestBody IbmsLightingLog ibmsLightingLog) {
        return toAjax(ibmsLightingLogService.updateById(ibmsLightingLog));
    }

    /**
     * 删除照明系统操作日志
     */
    @ApiOperation("删除照明系统操作日志")
    @PreAuthorize("@ss.hasPermi('lighting:lightingLog:remove')")
    @Log(title = "照明系统操作日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ibmsLightingLogService.removeBatchByIds(Arrays.asList(ids)));
    }
}
